home *** CD-ROM | disk | FTP | other *** search
- Path: Rezonet.net!news
- From: ray@ultimate-tech.com (Ray Dunn)
- Newsgroups: comp.lang.c
- Subject: Re: Q: Terminating program at EOF
- Date: 8 Jan 1996 05:33:43 GMT
- Organization: Ultimate Technographics Inc.
- Message-ID: <4cqabn$if9@ns.RezoNet.NET>
- References: <4cn66j$5r0@fnpx20.fnal.gov>
- NNTP-Posting-Host: 204.19.230.7
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.7
-
- In referenced article, Stephen Field says...
- >I've written a program that does the job, but it doesn't stop when it
- >reaches the end of the file....
-
- > char c_old=' ',c_new=' '; /* check for newlines with chars */
- > [much snipped]
- >/* while((c_new=fgetc(fptr_read))!=EOF){ */ /* old method for
- > removing EOF bug */
- > while(c_new!=EOF){ /* new method, still
- > doesn't work */
- > c_new=fgetc(fptr_read);
-
- After very quick scan of your code, there may be other problems:
- fgetc returns an *int* and EOF has the value -1. You assign it to a
- char, so if your chars are unsigned "c_new == EOF" is never true.
- --
- Ray Dunn (opinions are my own) | Phone: (514) 938 9050
- Montreal | Phax : (514) 938 5225
- ray@ultimate-tech.com | Home : (514) 630 3749
-
-